<?php
$this->Html->addCrumb('Services', '/services');
$this->Html->addCrumb($serviceInfo['Service']['name'],array('controller'=>'companies','action'=>'company_service',$serviceInfo['Service']['id']));
$this->Html->addCrumb($adInfo['Company']['name']);
$photoPresent = false;
?>
<?php
//css
echo $this->Html->css(array('jquery.cluetip'), false);
//js
echo $this->Html->script(array('jquery.hoverIntent.min','plugins/jquery.cluetip'), false);

$this->Html->scriptStart(array('inline' => false));
echo '
      $(function(){
        $("img.product").each(function(index, value) {
          $(this).attr("title",$(this).attr("rel"));
        });
        $("img.product").cluetip({attribute : "rel",cluetipClass: "islevow", splitTis]s]dtle : "|",  positionBy : "fixed" , leftOffset : 12, rightOffset : 0,
          hoverIntent: {
            sensitivity:  10,
            interval: 200,
            timeout: 0
          }
        });
      });
       ';
$this->Html->scriptEnd();
?>
<div>
  <div id="adContainer">
  <div id="adPhotoContainer">
  <?php if($adInfo['Ad']['single_photo']==='Y') {  
    $adPhoto = !empty($adInfo['AdPhotos'][0]) ? $adInfo['AdPhotos'][0] : null;
    if(!empty($adPhoto)) { $photoPresent = true;
    ?>
  
  
    <div id="adPhotoSection">
      <? if (!empty($adPhoto['image_path'])) { ?><div class="ad_single_photo"><?php echo $this->Html->image($adPhoto['image_path'], array('alt' => 'Ad Logo','title'=>$adPhoto['title'],'class'=>'center logo', 'rel'=>$adInfo['Company']['name'].'|'.$adInfo['Company']['description']))?></div> <?php } ?>
      <div id="adPhotoTextSection">
        <div class="ad_photo_text_title">
          <p><?php echo $adPhoto['title']?></p>
        </div>
        <div class="ad_photo_text">
          <p><?php echo $adPhoto['description']?></p>
        </div>        
      </div>
    </div>
    <?php } } else { ?>
    <div id="adMultiplePhotoSection">
      <?php if(sizeof($adInfo['AdPhotos'])>0 ){$photoPresent = true;}
      foreach($adInfo['AdPhotos'] as $adPhoto) { ?>      
      <div class="ad_photo"><?php echo $this->Html->image($adPhoto['image_path'], array('alt' => 'Product','title'=>'Product','class'=>'center product', 'rel'=>$adPhoto['title'].'|'.$adPhoto['description']))?></div>
      <?php } ?>
    </div>
    <?php }
    if(!$photoPresent) { ?>
      <div class="ad_single_photo"><?php echo $this->Html->image('large_ad_stock.jpeg', array('alt' => 'Ad','title'=>'Ad', 'class'=>'center logo'))?></div>
    <?php }
    ?>
    </div> <!--End #adPhotoContainer -->

    <div id="adTextSection">
      <div class="ad_title">
        <?php echo $adInfo['Company']['name'];?>
      </div>
      <div class="ad_description">

        <?php echo nl2br($adInfo['Company']['description']);?>

      </div>
      <?php
       if (!empty($adInfo['Company']['image_path'])) {
              echo '<p>' . $this->Html->image($adInfo['Company']['image_path'], array('alt' => $adInfo['Company'] ['name'],'class'=>'logo')) . '</p>';
            }
      ?>

      <div class="ad_contact_information">
        <?php if(!empty($adInfo['Company']['address'])) {?> <p><?php echo $adInfo['Company']['address']; ?></p> <?php } ?>
        <?php if (!empty($adInfo['Company']['phone'])) {?> <p><span class="contactMethod">P.</span><span class="contactMethodValue"> <a href="tel:<?php echo $adInfo['Company']['phone'];?>" class="contact"><?php echo $adInfo['Company']['phone'];?></a> </span></p> <?php } ?>
        <?php if (!empty($adInfo['Company']['phone_additional'])) {?> <p><span class="contactMethod">P.</span><span class="contactMethodValue"> <a href="tel:<?php echo $adInfo['Company']['phone_additional'];?>" class="contact"><?php echo $adInfo['Company']['phone_additional'];?></a> </span></p> <?php } ?>
        <?php if (!empty($adInfo['Company']['fax'])) {?> <p><span class="contactMethod">F.</span><span class="contactMethodValue"> <a href="tel:<?php echo $adInfo['Company']['fax'];?>" class="contact"><?php echo $adInfo['Company']['fax'];?></a> </span></p> <?php } ?>
        <?php if (!empty($adInfo['Company']['email'])) {?> <p><span class="contactMethod">E.</span><span class="contactMethodValue"> <a href="mailto:<?php echo $adInfo['Company']['email'];?>" class="contact"><?php echo $adInfo['Company']['email'];?></a> </span></p> <?php } ?>
        <?php if (!empty($adInfo['Company']['url'])) {?> <p><span class="contactMethod">W.</span><span class="contactMethodValue"> <a href="<?php echo $adInfo['Company']['url'];?>"  class="contact" target="_blank"><?php echo $adInfo['Company']['url'];?></a> </span></p> <?php } ?>
      </div>

     <?php if (!empty($adInfo['Company']['url'])) { ?>

      <div class="ad_link">
        <p><a href="#" target="_blank">More information here...</a>
        </p>
      </div>
      <?php } ?>
    </div>

  </div>
</div>